import 'package:flutter/material.dart';
import 'package:flutter_banner_swiper/flutter_banner_swiper.dart';
class BannerWidget extends StatelessWidget{
  List<String> banners=<String>[
    "assets/images/banner/banner1.jpg",
    "assets/images/banner/banner2.jpg",
     "assets/images/banner/banner3.jpg",
  ];

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    //计算宽高
    double width=MediaQuery.of(context).size.width;
    double height=width*540.0/1080.0;
    return Container(
      width: width,
      height: height,
      color: Colors.lime,
      //轮播组件
      child: BannerSwiper(
        //width  和 height 是图片的高宽比  不用传具体的高宽   必传
        height: 108,
        width: 54,
        //轮播图数目 必传
        length: banners.length,
        //轮播的item  widget 必传
        getwidget: (index) {
          return new GestureDetector(
              child:  Image.asset(banners[index%banners.length]),
              onTap: () {
                //点击后todo
              });
        },
      ),
    );
  }


}